package com.aimaoblog.front.service;

import com.aimaoblog.constant.ServerResponse;
import com.aimaoblog.front.api.SubjectFrontService;
import com.aimaoblog.front.dao.SubjectMapper;
import com.aimaoblog.pojo.Subject;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author PuaChen
 * @Create 2018-07-06 21:20
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class SubjectFrontServiceImpl implements SubjectFrontService {

    @Autowired
    private SubjectMapper subjectMapper;

    @Override
    public ServerResponse<List<Subject>> findSubject() {
        return ServerResponse.createSuccessAndData(subjectMapper.selectAll());
    }

    @Override
    public ServerResponse<List<Subject>> getHotSubject() {
        return ServerResponse.createSuccessAndData(subjectMapper.selectHotAll());
    }
}
